

#pragma OPENCL EXTENSION cl_arm_printf : enable
__kernel void hello_cl(__global uint *buffer) {
  // 计算过程
  size_t gidx = get_global_id(0);
  size_t gidy = get_global_id(1);
  size_t lidx = get_local_id(0);

  // [0x01 0x02 0x04 0x08] | [0x10 0x20 0x40 0x80]
  buffer[gidx + 4 * gidy] = (1 << gidx) | (0x10 << gidy);

  // 调用printf有坑，变量要强转为%指定的的数据!!!否则不打印
  printf("get_global_id(0)/get_global_size(0)=%lu/%lu    "
         "get_global_id(1)/get_global_size(1)=%lu/%lu    "
         "get_group_id(0)/get_num_groups(0)=%lu/%lu    "
         "get_group_id(1)/get_num_groups(1)=%lu/%lu    "
         "get_local_id(0)/get_local_size(0)=%lu/%lu    "
         "get_local_id(1)/get_local_size(1)=%lu/%lu\n",
         (ulong)get_global_id(0), (ulong)get_global_size(1),
         (ulong)get_global_id(0), (ulong)get_global_size(1),
         (ulong)get_group_id(0), (ulong)get_num_groups(0),
         (ulong)get_group_id(1), (ulong)get_num_groups(1),
         (ulong)get_local_id(0), (ulong)get_local_size(0),
         (ulong)get_local_id(1), (ulong)get_local_size(1));
}